package com.aligotec.bet;

import java.sql.Date;

import com.aligotec.lototron.Main;
import com.aligotec.lototron.db.DataBase;
import com.aligotec.utils.DateU;

public class Event {
	private long id;
	private Date date;
	private String code;
	private String name;
	
	public Event(){}
	public Event(String name, String code, String date){
		this.name = name;
		this.code = code;
		this.date = Date.valueOf(DateU.toCorrectDate(date));
	}
	
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public String getCode() {
		return code;
	}
	public void setCode(String code) {
		this.code = code;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public String toString(){
		return code + "|\t" + date.toString() + "|\t" + name + "";
	}
	
	public Event clone(){
		Event e = new Event(this.name, this.code, this.date.toString());
		e.setId(this.id);
		return e;
	}
	
	public void saveInDb(){
		
	}
	
	public void insertInDb(){
		DataBase db = Main.getDB();
		db.executeUpdate("INSERT INTO events (evn_vc_code, evn_vc_name, evn_dt_event)" +
				" VALUES ('" + code + "', '" + name + "','" + date.toString() + "')");
	}
	
	public Event search(String code){
		return null;
	}
}
